#!/usr/bin/env python
from os import path
from kroll import Module
Import('build')

def build_module_from_directory(dir):
	name = dir.lower().replace('.', '')
	module = Module(name, build.version, path.join(build.dir, 'modules', name))
	build.modules.append(module)

	env = build.env.Clone()
	env.Append(CPPDEFINES=[('MODULE_NAME', name), ('MODULE_VERSION', build.version)])

	SConscript(
		path.join(dir, 'SConscript'),
		variant_dir=path.join(build.dir, 'objs', 'modules', name),
		exports='build module env',
		duplicate=0)

Export('build_module_from_directory')
for dir in ['python', 'ruby', 'php']:
	build_module_from_directory(dir)
